FROM hn4930/telemac-debian:0.0.1
LABEL maintainer="peter.steiner@flussplan.at"

ARG TELEMAC_MASCARET_VER=v8p4r0

ARG TELEMAC_ROOT=/opt/telemac-mascaret

ARG TELEMAC_TARGET="openmpi"

# RUN apt-get -o Dpkg::Options::="--force-confold" install -q -y git
COPY ./telemac-mascaret  ${TELEMAC_ROOT}/${TELEMAC_MASCARET_VER}
# RUN ${TELEMAC_ROOT}/checkout.sh

COPY build.sh ${TELEMAC_ROOT}/
RUN chmod +x ${TELEMAC_ROOT}/build.sh

COPY systel.cfg ${TELEMAC_ROOT}
RUN ${TELEMAC_ROOT}/build.sh

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

COPY setenv.sh /etc/profile.d/setenv.sh
RUN chmod +x /etc/profile.d/setenv.sh

# 在 .bashrc 和 .profile 中加载 /etc/profile.d/ 中的环境变量
RUN echo 'source /etc/profile.d/*.sh' >> /root/.bashrc && \
    echo 'source /etc/profile.d/*.sh' >> /root/.profile


ENV TELEMAC_ROOT="${TELEMAC_ROOT}"
ENV TELEMAC_MASCARET_VER="${TELEMAC_MASCARET_VER}"
ENV TELEMAC_TARGET="${TELEMAC_TARGET}"

ENTRYPOINT [ "/entrypoint.sh", "/bin/bash" ]